package com.ruoyi.handing.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.handing.domain.AlgsEthicalReview;
import com.ruoyi.handing.service.IAlgsEthicalReviewService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 伦理审核Controller
 * 
 * @author ruoyi
 * @date 2023-03-18
 */
@RestController
@RequestMapping("/ethicalReview")
public class AlgsEthicalReviewController extends BaseController
{
    @Autowired
    private IAlgsEthicalReviewService algsEthicalReviewService;

    /**
     * 查询伦理审核列表
     */
//    @RequiresPermissions("review:ethicalReview:list")
    @GetMapping("/list")
    public TableDataInfo list(AlgsEthicalReview algsEthicalReview)
    {
        startPage();
        List<AlgsEthicalReview> list = algsEthicalReviewService.selectAlgsEthicalReviewList(algsEthicalReview);
        return getDataTable(list);
    }

    /**
     * 导出伦理审核列表
     */
//    @RequiresPermissions("review:ethicalReview:export")
    @Log(title = "伦理审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AlgsEthicalReview algsEthicalReview)
    {
        List<AlgsEthicalReview> list = algsEthicalReviewService.selectAlgsEthicalReviewList(algsEthicalReview);
        ExcelUtil<AlgsEthicalReview> util = new ExcelUtil<AlgsEthicalReview>(AlgsEthicalReview.class);
        util.exportExcel(response, list, "伦理审核数据");
    }

    /**
     * 获取伦理审核详细信息
     */
//    @RequiresPermissions("review:ethicalReview:query")
    @GetMapping(value = "/{ethicalReviewId}")
    public AjaxResult getInfo(@PathVariable("ethicalReviewId") Long ethicalReviewId)
    {
        return success(algsEthicalReviewService.selectAlgsEthicalReviewByEthicalReviewId(ethicalReviewId));
    }

    /**
     * 新增伦理审核
     */
//    @RequiresPermissions("review:ethicalReview:add")
    @Log(title = "伦理审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AlgsEthicalReview algsEthicalReview)
    {
        return toAjax(algsEthicalReviewService.insertAlgsEthicalReview(algsEthicalReview));
    }

    /**
     * 修改伦理审核
     */
//    @RequiresPermissions("review:ethicalReview:edit")
    @Log(title = "伦理审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AlgsEthicalReview algsEthicalReview)
    {
        return toAjax(algsEthicalReviewService.updateAlgsEthicalReview(algsEthicalReview));
    }

    /**
     * 删除伦理审核
     */
//    @RequiresPermissions("review:ethicalReview:remove")
    @Log(title = "伦理审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ethicalReviewIds}")
    public AjaxResult remove(@PathVariable Long[] ethicalReviewIds)
    {
        return toAjax(algsEthicalReviewService.deleteAlgsEthicalReviewByEthicalReviewIds(ethicalReviewIds));
    }
}
